import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;

/**
 * @Question UploadFile
 * @Date 2022/10/18 11:20
 * @Solution
 */
@MultipartConfig
@WebServlet("/upload")
public class UploadFile extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Part part = req.getPart("MyFile");
        System.out.println(part.getSize());
        System.out.println(part.getSubmittedFileName());
        System.out.println(part.getContentType());
        part.write("D:/a");
    }
}
